#ifndef ASGKA_IMPLEMENT_H
#define ASGKA_IMPLEMENT_H

// Network
#include "asgka_network.h"

// Threads
#include "TCPListenThread.h"
#include "TCPRecvThread.h"
#include "UDPRecvThread.h"
#include "asgkaCreateAgreementThread.h"

// Objects
#include "memberCenter.h"
#include "GroupCenter.h"

class asgka_implement
{
public:
	asgka_implement();
	~asgka_implement();

	void asgka_setup(const std::string &mylocalname);
	void asgka_close();
	void createAGroup(const std::string &groupname);
	void leaveAGroup(const std::string &groupname);
	void joinAGroup(const std::string &groupname, const std::string &groupleadername);

private:
	void asgka_exit();
	void chooseAndInvite(std::map<std::string, u_long> &member_list, singleGroup *group);
	void publicMemberList(std::map<std::string, u_long> &member_list, const std::string &groupname);
	void sendLeaveGroupMsg(const std::string &groupname);

private:
	//Threads
	TCPListenThread *m_tcp_listen;
	UDPRecvThread   *m_udp_recv;

	// Objects
	memberCenter *m_member_center;
	groupCenter  *m_group_center;

	singleMember *m_myself;
};

#endif